//
//  SCStatusModel.swift
//  weibo
//
//  Created by 阿城 on 15/12/9.
//  Copyright © 2015年 阿城. All rights reserved.
//

import UIKit

class SCStatusModel: NSObject {
    
    var id: Int64 = 0
    var text: String?
    var source: String?
    var user: SCStatusUserModel?
    var retweeted_status: SCStatusModel?
    var pic_urls: [SCPictureInfo]?
    var created_at: String?
    // 转发
    var reposts_count: Int = 0
    // 评论数
    var comments_count: Int = 0
    // 表态数
    var attitudes_count: Int = 0
    
    init(dict: [String:AnyObject]) {
        super.init()
        pic_urls = nil
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            user = SCStatusUserModel(dict: value as! [String:AnyObject])
        }else if key == "retweeted_status" {
            retweeted_status = SCStatusModel(dict: value as! [String:AnyObject])
        }
        else if key == "pic_urls"{
            let tempArr = value as! [[String:AnyObject]]
            var pics = [SCPictureInfo]()
            for pic in tempArr{
                pics.append(SCPictureInfo(dict: pic))
            }
            pic_urls = pics
        }
        else{
            super.setValue(value, forKey: key)
        }
    }
    
}
